

import {Component,ViewChild} from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators ,ReactiveFormsModule } from '@angular/forms';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA}  from '@angular/material';
import {BsModalService,BsModalRef} from 'ngx-bootstrap/modal';
import { StudentdetailComponent } from './Student-detail.component';
import { StudentcreateComponent } from './Student-create.component';

@Component({
    selector: 'student-curd',
    templateUrl: 'student-curd.component.html',
    styleUrls:["student-curd.component.css"]
    })
    export class StudentcurdComponent{

    @ViewChild('detail',{ static:false}) objDetail:StudentdetailComponent;
    @ViewChild('create',{ static:false}) objCreate:StudentcreateComponent;

    modalRef:BsModalRef;

    objListShow=true;


    createNew(){
    const initialState = {parentComponent: this};
    this.modalRef = this.modalService.show(StudentcreateComponent,{initialState});
    }

    childCancel(childComp)
    {
    this.modalRef.hide();
    }

    showDetailWithData(data){
    this.modalRef.hide();
    const initialState = {parentComponent: this};
    this.modalRef = this.modalService.show(StudentdetailComponent,{initialState});
    this.modalRef.content.setValue(data);
    }


    //getters for fields
    constructor(public dialog:MatDialog,private modalService:BsModalService){}
    }
